<template>
  <!-- 小组件列表 -->
  <div class="widgetList">
    <div class="item" :class="{hoverBlock:index==5}" v-for="(widget,index) in widgetList" :key="index" @mousedown="mousedown($event,widget)" draggable="true">
      <div class="itemBox">
        <img :src="require('@/assets/icon/'+widget.icon)">
        <div>{{widget.label}}</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "widgetList",
  props: {
    widgetList:{//组件列表
      type: Array,
      required: true,
      default: () =>[]
    },
  },
  data () {
    return { }
  },
  methods: {
    // 鼠标按下事件(原生事件mousedown)
    mousedown(e,widget){
      this.$emit('onWidgetMouseDown', e, widget)
    }
  },
}
</script>

<style lang="less" scoped>
.widgetList{
  width: 100%;
  height: 100%;
  margin-top: 10px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  .item{
    font-size: 14px;
    color: #666;
    padding: 5px;
    margin: 7px;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    .itemBox{
      width: 60px;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
    }
    &:hover{
      background: #E6F0FE;
    }
    .tips{
      color:#e6a23c;
      position: absolute;
      right: 0;
      &:hover{
        .tipsCon {
          display: block;
        }
      }
      .tipsCon{
        display: none;
        background: #fff;
        width: 190px;
        padding: 10px;
        border: 1px solid #cdcdcd;
        position: absolute;
        right: 0;
        z-index: 9;
      }
    }
  }
  .hoverBlock{
    display: block;
  }
}
</style>